<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ClassBaseInfo extends Model
{
    protected $table = 'class_base_info';

    public $timestamps = FALSE;

    //获取课程关联
    public function class_base()
    {
        return $this->hasOne('App\Models\ClassBase','id','class_base_id');
    }

    //老师
    public function teacher()
    {
        return $this->hasOne('App\Models\Teacher','id','teacher_id');
    }

    //课室
    public function classsroom()
    {
        return $this->hasOne('App\Models\Classroom','id','class_classroom_id');
    }

    //查询店铺名
    public function store()
    {
        return $this->hasOne('App\Models\Store','id','store_id');
    }

    /**
     * 时间获取器
     */
    public function getClassWeekAttribute($value)
    {
        switch ($value){
            case '1':
                $week = '星期一';
                break;
            case '2':
                $week = '星期二';
                break;
            case '3':
                $week = '星期三';
                break;
            case '4':
                $week = '星期四';
                break;
            case '5':
                $week = '星期五';
                break;
            case '6':
                $week = '星期六';
                break;
            case '7':
                $week = '星期日';
                break;
        }
        return $week;
    }
}
